// pages/search/search.js
var app = getApp();
var host = app.globalData.host;
Page({
    data: {
        result: [],
        name: '',
        goodsNames: [
            { "goodsName": "机器学习" },
            { "goodsName": "Spring Cloud" },
            { "goodsName": "网站" },
            { "goodsName": "Redis" },
            { "goodsName": "Memcached" },
            { "goodsName": "Vue" },
            { "goodsName": "Spring MVC" },
            { "goodsName": "小程序" },
            { "goodsName": "Oracle" },
            { "goodsName": "Java" }
        ]
    },
    //清除搜索框的内容
    clearInput: function() {
        this.setData({
            clearShow: false,
            searchContent: ''
        })
    },
    formSubmit: function(e) {
        console.log(e)
        var that = this;
        var goodsName = e.detail.value.goodsName;
        console.log(goodsName);


        if (goodsName != "") {
            wx.request({
                url: host + '/api/goods/getGoodsList',
                method: 'GET',
                data: { "goodsName": goodsName },
                header: {
                    'Content-Type': 'application/json'
                },
                success: function(res) {
                    var result = res.data.data;
                    that.setData({ result: result });
                }
            })
        }

    },
    seeDetail: function(e) {
        console.log(e)
        var id = e.currentTarget.id;
        wx.navigateTo({
            url: '../goodsDetail/goodsDetail?goodsId=' + id
        })
    }
})